Make the initial focus in dialogs work as intended
authorMatthias Clasen <mclasen@redhat.com>
Wed, 25 Aug 2010 04:43:16 +0000 (00:43 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 25 Aug 2010 04:43:16 +0000 (00:43 -0400)
We had code that tried to prevent selecting the text in the label
if we end up focusing a label, but it didn't take effect, because
we were moving the focus into the label again afterwards.

gtk/gtkdialog.c

index 01aec48ca854f2f365d28eb57bbbcccc79aa867a..1c070c2de381f8779ef2b6bf5eeb86c49317d1e0 100644 (file)
@@ -419,25 +419,28 @@ gtk_dialog_map (GtkWidget *widget)
     {
       GList *children, *tmp_list;
       GtkWidget *first_focus = NULL;
-      
-      do 
-       {
-         g_signal_emit_by_name (window, "move_focus", GTK_DIR_TAB_FORWARD);
+
+      do
+        {
+          g_signal_emit_by_name (window, "move_focus", GTK_DIR_TAB_FORWARD);
 
           focus = gtk_window_get_focus (window);
-         if (first_focus == NULL)
+          if (first_focus == NULL)
             first_focus = focus;
-         else if (first_focus == focus)
+          else if (first_focus == focus)
+            {
+              if (GTK_IS_LABEL (focus) &&
+                  !gtk_label_get_current_uri (GTK_LABEL (focus)))
+                gtk_label_select_region (GTK_LABEL (focus), 0, 0);
+              break;
+            }
+          if (!GTK_IS_LABEL (focus))
             break;
-         if (!GTK_IS_LABEL (focus))
-           break;
-          if (!gtk_label_get_current_uri (GTK_LABEL (focus)))
-            gtk_label_select_region (GTK_LABEL (focus), 0, 0);
-       }
+        }
       while (TRUE);
 
       tmp_list = children = gtk_container_get_children (GTK_CONTAINER (priv->action_area));
-      
+
       while (tmp_list)
        {
          GtkWidget *child = tmp_list->data;